import { useRef } from 'react'
import ModalStore from './useModalStore'
import type { ComType } from './type'

const useModal = (modal?: ComType) => {
	const modalRef = useRef<ComType>()

	if (modal) {
		modalRef.current = modal
	} else {
		modalRef.current = new ModalStore(false)
	}

	return [modalRef.current]
}

export default useModal
